package com.gopay.common.cps.dao.holiday.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.constants.holiday.HolidayType;
import com.gopay.common.cps.dao.holiday.HolidayInformationDAO;
import com.gopay.common.domain.holiday.HolidayInformation;

/**
 * @HolidayInformationDAOImpl.java
 * @author wanggang
 * @2014-9-9 下午2:25:16 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository(value = "holidayInformationDAO")
public class HolidayInformationDAOImpl extends BaseDAOImpl<HolidayInformation, Serializable> implements
        HolidayInformationDAO {

    @Override
    public HolidayInformation getHolidayInformationByYearandMonth(HolidayType holidayType, String year, String month) {
        DetachedCriteria criteria = DetachedCriteria.forClass(HolidayInformation.class);
        criteria.add(Restrictions.eq("holidayType", holidayType.value));
        criteria.add(Restrictions.eq("year", year));
        criteria.add(Restrictions.eq("month", month));
        List<HolidayInformation> holidayList = this.findByCriteria(criteria);
        return holidayList.size() > 0 ? holidayList.get(0) : null;
    }

}
